from stark.service.stark import StarkConfig
from crm_app import models
from crm_app.permission.base import BASERbacPermission


class StudentConfig(BASERbacPermission, StarkConfig):
    def display_class_list(self, row=None, header=False):
        if header:
            return "已报班级"

        class_list = row.class_list.all()
        class_name_list = ["%s%s期" % (item.course.name, item.semester) for item in class_list]

        return ",".join(class_name_list)

    list_display = ["username", "customer", display_class_list]